package operation;

import book.Book;
import book.BookList;

/**
 * Created with IntelliJ IDEA.
 * Description：
 * User：user
 * DATE:2021-10-29
 * Time:20:21
 */
public class ReturnOperation implements IOPeration{
    @Override
    public void work(BookList bookList){
        System.out.println("归还书籍");
        System.out.println("请输入需要借阅的名字");
        String name = scanner.nextLine();
        int size = bookList.getUsedSize();
        for (int i = 0; i < size; i++) {
            Book bookCurrent = bookList.getBook(i);
            if(bookCurrent.getName().equals(name)){
                bookCurrent.setBorrowed(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("归还失败");
    }
}
